package com.vr.cloudpicture.api.imagesearch;

import com.vr.cloudpicture.api.imagesearch.model.ImageSearchResult;
import com.vr.cloudpicture.api.imagesearch.sub.GetImageFirstUrlApi;
import com.vr.cloudpicture.api.imagesearch.sub.GetImageListApi;
import com.vr.cloudpicture.api.imagesearch.sub.GetImagePageApi;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 图像搜索 API门面
 *
 * @author hzh
 * @date 2025/05/20
 */
@Slf4j
public class ImageSearchApiFacade {
    /**
     * 搜索图片
     *
     * @param imageUrl 图片 URL
     * @return {@code List<ImageSearchResult> }
     */
    public static List<ImageSearchResult> searchImage(String imageUrl) {
        String imagePageUrl = GetImagePageApi.getImagePageUrl(imageUrl);
        String imageFirstUrl = GetImageFirstUrlApi.getImageFirstUrl(imagePageUrl);
        return GetImageListApi.getImageList(imageFirstUrl);
    }

    public static void main(String[] args) {
        // test搜图功能
        String imgUrl="https://www.beijing.gov.cn/renwen/bjgk/mygk/myfg/202208/W020220812574023612181.jpg";
        List<ImageSearchResult> imageSearchResults = searchImage(imgUrl);
        System.out.println(imageSearchResults);
    }
}
